package org.acme.server.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;

import java.util.Date;

/*
 * @className: SysServerMessage
 * @author: chentao
 * @date: 2025/3/7 下午2:24
 * @Version: 1.0
 * @description:
 */
@Data
@TableName(value = "sys_server_message")
public class SysServerMessage extends Model<SysServerMessage> {

    @TableId(type = IdType.ASSIGN_ID)
    private String id;

    @TableField(value = "from_id")
    private String fromId;

    @TableField(value = "to_id")
    private String toId;

    @TableField(value = "type")
    private String type;

    @TableField(value = "message")
    private String message;

    @TableField(value = "status")
    private String status;

    @TableField(value = "create_time")
    private Date createTime;

    @TableField(value = "update_time")
    private Date updateTime;

    public void recalculateFields(){
        if (this.createTime == null){
            this.createTime = new Date();
        }
        this.updateTime = new Date();
    }
}
